import { UserConfigExport, ConfigEnv } from 'vite'
import vue from '@vitejs/plugin-vue'
import viteCompression from 'vite-plugin-compression'
import path from 'path'
const resolve = dir => path.join(__dirname, dir)
import viteSvgIcons from 'vite-plugin-svg-icons'
// https://vitejs.dev/config/
export default ({ command }: ConfigEnv): UserConfigExport => {
  return {
    plugins: [
      vue(),
      viteSvgIcons({
        // 指定需要缓存的图标文件夹
        iconDirs: [path.resolve(process.cwd(), 'src/icons')],
        // 指定symbolId格式
        symbolId: 'icon-[dir]-[name]'
      }),
      viteCompression({
        verbose: true,
        disable: false,
        threshold: 3072,
        algorithm: 'gzip',
        ext: '.gz'
      }),
    ],
    resolve: {
      alias: {
        '@': resolve('src')
      }
    },
    base: '/vite2-vue3-element-plus/',
    server: {
      port: 2021,
      open: true
    }
  }
}

